<!DOCTYPE html>
<html lang='en'>

<head>
  <meta charset='UTF-8'>
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <meta name='viewport' content='width=device-width, initial-scale=1.0'>
  <title>工资想过万，键盘要敲烂</title>
  <style>

  </style>
</head>

<body>
  <button>买彩票</button>
  <script>
    document.querySelector('button').onclick = function () {
      let p = new Promise((resolve, reject) => {
        console.log('有钱了就娶你');
        setTimeout(() => {
          let money = parseInt(Math.random() * 200)
          console.log(money);
          if (money >= 100) {
            resolve(`中奖了，有${money}万，来娶你`)
          } else {
            reject(`没钱了`)
          }
        }, 1000)
      })
      p.then((res) => {
        console.log(res);
      }).catch((ele) => {
        console.log(ele);
      })
    }
  </script>
</body>

</html>